package com.xymc.webmgr.controller;

import com.alibaba.fastjson.JSONObject;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xymc.webmgr.utils.RequestParametersUtil;
import org.springframework.web.bind.annotation.*;
import com.xymc.webmgr.service.TUserService;

/**
 * <p>用户表<p>
 * @version : 1.0
 * @Author : li_hao
 * @Description : 前端控制器
 * @Date : 2022-01-28
 **/
@RestController
@RequestMapping("/user")
public class TUserController {

    @Resource
    private TUserService tUserService;


    /**
     * 新增
     *
     * @return
     */
    @PostMapping("/create")
    public JSONObject create(@RequestBody JSONObject reqJson, HttpServletRequest request, HttpServletResponse response) {
        return tUserService.create(reqJson);
    }


    /**
     * 修改
     *
     * @return
     */
    @PostMapping("/update")
    public JSONObject update(@RequestBody JSONObject reqJson, HttpServletRequest request, HttpServletResponse response) {
        return tUserService.update(reqJson);
    }

    /**
     * 删除
     *
     * @return
     */
    @PostMapping("/delete")
    public JSONObject delete(@RequestBody JSONObject reqJson, HttpServletRequest request, HttpServletResponse response) {
        return tUserService.delete(reqJson);
    }


    /**
     * 查询详情
     *
     * @return
     */
    @GetMapping("/getDetail/{id}")
    public JSONObject getDetail(@PathVariable String id, HttpServletRequest request, HttpServletResponse response) {
        return tUserService.getDetail(id);
    }


    /**
     * 查询分页列表
     *
     * @return
     */
    @GetMapping("/getPageList")
    public JSONObject getPageList(HttpServletRequest request, HttpServletResponse response) {
        return tUserService.getPageList(RequestParametersUtil.getRequestParametersRetJson(request));
    }

    /**
     * 查询列表（不分页）
     *
     * @return
     */
    @GetMapping("/getList")
    public JSONObject getList(HttpServletRequest request, HttpServletResponse response) {
        return tUserService.getList(RequestParametersUtil.getRequestParametersRetJson(request));
    }

}